﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://itcast.cn/common/" prefix="it"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<TITLE>客户列表</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!-- Bootstrap Core CSS -->
<link href="${pageContext.request.contextPath }/css/bootstrap.min.css"
	rel="stylesheet">

<!-- MetisMenu CSS -->
<link href="${pageContext.request.contextPath }/css/metisMenu.min.css"
	rel="stylesheet">

<!-- DataTables CSS -->
<link
	href="${pageContext.request.contextPath }/css/dataTables.bootstrap.css"
	rel="stylesheet">

<!-- Custom CSS -->
<link href="${pageContext.request.contextPath }/css/sb-admin-2.css"
	rel="stylesheet">

<!-- Custom Fonts -->
<link
	href="${pageContext.request.contextPath }/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link href="${pageContext.request.contextPath }/css/boot-crm.css"
	rel="stylesheet" type="text/css">

<LINK href="${pageContext.request.contextPath }/css/Style.css"
	type=text/css rel=stylesheet>
<LINK href="${pageContext.request.contextPath }/css/Manage.css"
	type=text/css rel=stylesheet>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/js/jquery-1.4.4.min.js"></script>
<link href="${pageContext.request.contextPath }/css/bootstrap.min.css"
	type=text/css rel="stylesheet">
<script type="text/javascript">
	function deleteDepartment(departmentId) {
		if(confirm('确实要删除该部门吗?')) {
			$.post("${pageContext.request.contextPath}/deleteDepartment.action",
					{"departmentId":departmentId},
					function(data){
						alert("客户删除更新成功！");
						window.location.reload();
			});
		}
	}
</script>
<style type="text/css">
#sButton2 {
	width: 70px;
	height: 21px;
	line-height: 21px;
	padding: 0 11px;
	background: #02bafa;
	border: 1px #26bbdb solid;
	border-radius: 3px;
	color: #fff;
	display: inline-block;
	text-decoration: none;
	font-size: 12px;
	outline: none
}
</style>
<META content="MSHTML 6.00.2900.3492" name=GENERATOR>
</HEAD>
<BODY>
	<TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
		<TBODY>
			<TR>
				<TD width=15><IMG
					src="${pageContext.request.contextPath }/images/new_019.jpg"
					border=0></TD>
				<TD width="100%"
					background="${pageContext.request.contextPath }/images/new_020.jpg"
					height=20></TD>
				<TD width=15><IMG
					src="${pageContext.request.contextPath }/images/new_021.jpg"
					border=0></TD>
			</TR>
		</TBODY>
	</TABLE>
	<FORM id="customerForm" name="customerForm" action="${pageContext.request.contextPath }/departmentList.action" method=post>
		<TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
			<TBODY>
				<TR>
					<TD width=15 background=${pageContext.request.contextPath } /images/new_022.jpg>
						<IMG src="${pageContext.request.contextPath }/images/new_022.jpg" border=0>
					</TD>
					<TD vAlign=top width="100%" bgColor=#ffffff>
						<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
							<TR>
								<TD class=manageHead>当前位置：部门管理 &gt; 部门列表</TD>
							</TR>
							<TR>
								<TD height=2></TD>
							</TR>
						</TABLE>
						<TABLE borderColor=#cccccc cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
							<TBODY>
								<TR>
									<TD height=25>
										<TABLE cellSpacing=0 cellPadding=2 border=0>
											<TBODY>
												<TR>
													<TD>部门名称：</TD>
													<TD><INPUT class=textbox id=sChannel2 maxLength=50
														name="departmentName" value="${departmentName}"></TD>

													<TD>&nbsp;&nbsp;部门领导：</TD>
													<TD><INPUT class=textbox id=sChannel2 maxLength=50
														name="userName" value="${userName}"></TD>
													<TD>&nbsp;<INPUT id=sButton2 type=submit value=" 筛选 "
														name=sButton2>
													</TD>
													<TD>&nbsp;&nbsp; 
														<c:if test="${loginUserAoth['4'].getIsChecked()==1}">
															<a id=sButton2 href="#" style="text-decoration: none" data-toggle="modal" data-target="#departmentAddDialog">
																&nbsp;添加
															</a>
														</c:if>
													</TD>
												</TR>
											</TBODY>
										</TABLE>
									</TD>
								</TR>
								<!-- 列表显示 -->
								<TR>
									<TD>
										<TABLE id=grid
											style="BORDER-TOP-WIDTH: 0px; FONT-WEIGHT: normal; BORDER-LEFT-WIDTH: 0px; BORDER-LEFT-COLOR: #cccccc; BORDER-BOTTOM-WIDTH: 0px; BORDER-BOTTOM-COLOR: #cccccc; WIDTH: 100%; BORDER-TOP-COLOR: #cccccc; FONT-STYLE: normal; BACKGROUND-COLOR: #cccccc; BORDER-RIGHT-WIDTH: 0px; text-DECORATION: none; BORDER-RIGHT-COLOR: #cccccc"
											cellSpacing=1 cellPadding=2 rules=all border=0>
											<TBODY>
												<TR
													style="FONT-WEIGHT: bold; FONT-STYLE: normal; BACKGROUND-COLOR: #eeeeee; TEXT-DECORATION: none">
													<TD>部门ID</TD>
													<TD>部门名称</TD>
													<TD>部门主管</TD>
													<TD>备注</TD>
													<TD>操作</TD>
												</TR>
												<c:forEach items="${page.rows}" var="department">
													<TR
														style="FONT-WEIGHT: normal; FONT-STYLE: normal; BACKGROUND-COLOR: white; TEXT-DECORATION: none">
														<TD>${department.departmentId}</TD>
														<TD>${department.departmentName}</TD>
														<TD>${department.userName}</TD>
														<TD>${department.departmentRemark}</TD>
														<TD>
														<c:if test="${loginUserAoth['5'].getIsChecked()==1}">
															<a  href="#"  data-toggle="modal" data-target="#departmentEditDialog" onclick="editdepartment(${department.departmentId})">
																修改
															</a>
														</c:if>
														<c:if test="${loginUserAoth['6'].getIsChecked()==1}">
															<a href="#" onclick="deleteDepartment(${department.departmentId})">删除</a>
														</c:if>
														</TD>
													</TR>
												</c:forEach>
											</TBODY>
										</TABLE>
									</TD>
								</TR>
								<!-- 分页 -->
								<TR>
									<TD><SPAN id=pagelink>
											<div class="col-md-12 text-right">
												<it:page url="${pageContext.request.contextPath }/departmentList.action" />
											</div>
									</SPAN></TD>
								</TR>
							</TBODY>
						</TABLE>
					</TD>
					<TD width=15
						background="${pageContext.request.contextPath }/images/new_023.jpg">
						<IMG src="${pageContext.request.contextPath }/images/new_023.jpg"
						border=0>
					</TD>
				</TR>
			</TBODY>
		</TABLE>
	</FORM>
	<TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
		<TBODY>
			<TR>
				<TD width=15><IMG
					src="${pageContext.request.contextPath }/images/new_024.jpg"
					border=0></TD>
				<TD align=middle width="100%"
					background="${pageContext.request.contextPath }/images/new_025.jpg"
					height=15></TD>
				<TD width=15><IMG
					src="${pageContext.request.contextPath }/images/new_026.jpg"
					border=0></TD>
			</TR>
		</TBODY>
	</TABLE>
	<!-- 修改部门对话框 -->
	<div class="modal fade" id="departmentEditDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">修改客户信息</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="editDepartment_form">
					
						<input type="hidden" id="addDepartmentId" name="departmentId" />
						
						<div class="form-group">
							<label for="departmentName" class="col-sm-2 control-label">部门名称</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addDepartmentName" placeholder="部门名称" name="departmentName">
							</div>
						</div>
						<div class="form-group">
							<label for="departmentManager" class="col-sm-2 control-label">部门主管</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addUserName" placeholder="部门主管" name="userName">
							</div>
						</div>
						<div class="form-group">
							<label for="departmentRemark" class="col-sm-2 control-label">部门备注</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addDepartmentRemark" placeholder="部门备注" name="departmentRemark">
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" onclick="updateDepartment()">保存修改</button>
				</div>
			</div>
		</div>
	</div>
	<!-- 增加部门对话框 -->
	<div class="modal fade" id="departmentAddDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="myModalLabel">添加部门</h4>
				</div>
				<div class="modal-body">
					<form class="form-horizontal" id="addDepartment_form">
						
						<div class="form-group">
							<label for="departmentName" class="col-sm-2 control-label">部门名称</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addDepartmentName" placeholder="部门名称" name="departmentName">
							</div>
						</div>
						
						<div class="form-group">
							<label for="edit_mobile" class="col-sm-2 control-label">部门主管</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addUserName" placeholder="部门主管" name="userName">
							</div>
						</div>
						<div class="form-group">
							<label for="edit_zipcode" class="col-sm-2 control-label">部门备注</label>
							<div class="col-sm-10">
								<input type="text" class="form-control" id="addDepartmentRemark" placeholder="部门备注" name="departmentRemark">
							</div>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="button" class="btn btn-primary" onclick="addDepartment()">添加</button>
				</div>
			</div>
		</div>
	</div>



	<!-- jQuery -->
	<script src="${pageContext.request.contextPath }/js/jquery.min.js"></script>

	<!-- Bootstrap Core JavaScript -->
	<script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>

	<!-- Metis Menu Plugin JavaScript -->
	<script src="${pageContext.request.contextPath }/js/metisMenu.min.js"></script>

	<!-- DataTables JavaScript -->
	<script src="${pageContext.request.contextPath }/js/jquery.dataTables.min.js"></script>
	<script src="${pageContext.request.contextPath }/js/dataTables.bootstrap.min.js"></script>

	<!-- Custom Theme JavaScript -->
	<script src="${pageContext.request.contextPath }/js/sb-admin-2.js"></script>

	<script type="text/javascript">
		function editdepartment(departmentId) {
			$.ajax({
				type:"get",
				url:"${pageContext.request.contextPath }/toUpdateDepartment.action",
				data:{"departmentId":departmentId},
				success:function(data) {  
					$("#addDepartmentId").val(data.departmentId);
					$("#addDepartmentName").val(data.departmentName);
					$("#addUserName").val(data.userName);
					$("#addDepartmentRemark").val(data.departmentRemark)
				}
			});
		}
		function updateDepartment() {
			$.post(
					"${pageContext.request.contextPath }/updateDepartment.action",
					$("#editDepartment_form").serialize(),
					function(data){
						alert("客户信息更新成功！");
						window.location.reload();
					}
			);
		}
		function addDepartment() {
	        $.post(
	        		"${pageContext.request.contextPath }/addDepartment.action",
	        		$("#addDepartment_form").serialize(),
	        		function(data){
		          		alert("新员工添加成功！");
		          		window.location.reload();
	        });
	      }
		function deleteCustomer(id) {
			if(confirm('确实要删除该客户吗?')) {
				$.post("${pageContext.request.contextPath }/customer/delete.action",{"id":id},function(data){
					alert("客户删除更新成功！");
					window.location.reload();
				});
			}
		}
	</script>




</BODY>
</HTML>
